package com.le.tester.book.concurrentjavafight.l6_2_1;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * createTime：2022/10/18 15:51
 * description：基于线程池的Web服务器
 */
public class TaskExecutionWebServer {
    private static final int N_THREADS = 100;

    private static final ExecutorService exec = Executors.newFixedThreadPool(N_THREADS);

    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(80);
        while (true) {
            final Socket connection = serverSocket.accept();

            Runnable task = () -> {
                System.out.println("exec");
            };
            exec.execute(task);
        }
    }
}
